package com.gollum.common.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.gollum.jpa.domain.PageQueryRequest;

import java.util.Objects;

/**
 * 自定义分页插件
 *
 * @author Herther
 * @createTime 2022年09月12日 01:10:00
 * @since 1.0.0
 */
public class PageContextHolder {

    private static final TransmittableThreadLocal<PageQueryRequest> PAGE_QUERY_HOLDER = new TransmittableThreadLocal<>();


    public static void set(PageQueryRequest pageQueryRequest)
    {
        if (Objects.nonNull(pageQueryRequest)){
            PAGE_QUERY_HOLDER.set(pageQueryRequest);
        }
    }


    public static PageQueryRequest get()
    {
        return PAGE_QUERY_HOLDER.get();
    }

    public static void remove(){
        PAGE_QUERY_HOLDER.remove();
    }

}
